What is @esbuild-plugins/node-modules-polyfill?
@esbuild-plugins/node-modules-polyfill is a plugin for esbuild that provides polyfills for Node.js core modules. This allows developers to use Node.js modules in environments where they are not natively supported, such as in the browser.
Polyfill Node.js core modules
This feature allows you to polyfill Node.js core modules like 'fs', 'path', etc., so that they can be used in environments like the browser. The code sample demonstrates how to use the NodeModulesPolyfillPlugin with esbuild to bundle an application.
const esbuild = require('esbuild');
const { NodeModulesPolyfillPlugin } = require('@esbuild-plugins/node-modules-polyfill');
esbuild.build({
entryPoints: ['app.js'],
bundle: true,
outfile: 'out.js',
plugins: [NodeModulesPolyfillPlugin()]
}).catch(() => process.exit(1));